import 'package:finance_app/src/entities/sub_next_billing_item_entity.dart';
import 'package:finance_app/src/utils/date_time_utils.dart';

subNextBillingItemEntityFromJson(SubNextBillingItemEntity data, Map<String, dynamic> json) {
	if (json['start_at'] != null) {
		data.startAt = json['start_at'].toString();
	}
	if (json['end_at'] != null) {
		data.endAt = json['end_at'].toString();
	}
	if (json['next_price'] != null) {
		data.nextPrice = json['next_price'] is String
				? num.tryParse(json['next_price'])
				: json['next_price'];
	}
	if (json['price'] != null) {
		data.price = json['price'] is String
				? num.tryParse(json['price'])
				: json['price'];
	}
	if (json['original_price'] != null) {
		data.originalPrice = json['original_price'] is String
				? num.tryParse(json['original_price'])
				: json['original_price'];
	}
	if (json['upgrade_refund_price'] != null) {
		data.upgradeRefundPrice = json['upgrade_refund_price'] is String
				? num.tryParse(json['upgrade_refund_price'])
				: json['upgrade_refund_price'];
	}
	return data;
}

Map<String, dynamic> subNextBillingItemEntityToJson(SubNextBillingItemEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['start_at'] = entity.startAt;
	data['end_at'] = entity.endAt;
	data['next_price'] = entity.nextPrice;
	data['price'] = entity.price;
	data['original_price'] = entity.originalPrice;
	data['upgrade_refund_price'] = entity.upgradeRefundPrice;
	return data;
}